package com.ruoyi.provider.api.factory

import com.ruoyi.provider.api.RemoteProviderService
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.cloud.openfeign.FallbackFactory
import org.springframework.stereotype.Component

/**
 *@author YanYu
 *@date 2024/9/22 14:33
 */
@Component
class RemoteProviderFallbackFactory : FallbackFactory<RemoteProviderService> {
    companion object {
        private val log: Logger = LoggerFactory.getLogger(RemoteProviderFallbackFactory::class.java)
    }

    override fun create(cause: Throwable): RemoteProviderService {
        log.error("提供者服务调用失败:{}", cause.message)
        return object : RemoteProviderService {
            override fun providerDemo(): String {
                return "提供者服务调用失败"
            }

            override fun providerDemoLarge(): String {
                return "提供者服务调用失败"
            }
        }
    }

}